<template>
  <div style="min-height: 500px">
    <table class="mytable">
      <tr>
        <th style="width: 20%">计划名称</th>
        <td>{{entity.title}}</td>
      </tr>
      <tr>
        <th>盘点周期</th>
        <td>{{entity.zqName}}</td>
      </tr>
      <tr v-if="state.PlanZq.once === entity.zq">
        <th>盘点日期范围</th>
        <td>{{entity.cdefine1}} -- {{entity.cdefine2}}</td>
      </tr>
      <tr v-if="state.PlanZq.month === entity.zq">
        <th>盘点日期范围</th>
        <td>每月{{entity.cdefine1}}号到{{entity.cdefine2}}号</td>
      </tr>
      <tr v-if="state.PlanZq.jidu === entity.zq">
        <th>盘点日期范围</th>
        <td>
          <span v-if="entity.cdefine4 === '1'" >季度初</span><span v-else-if="entity.cdefine4 === '2'" >季度中</span> <span v-else>季度末</span>
          {{entity.cdefine1}}号到{{entity.cdefine2}}号
        </td>
      </tr>
      <tr>
        <th>盘点类型</th>
        <td>{{entity.pdlxName}}</td>
      </tr>
      <tr v-if="entity.cdefine4">
        <th>最小盘点比率</th>
        <td>{{entity.cdefine4}}%</td>
      </tr>
      <tr  v-if="entity.cdefine5">
        <th>最大重复比率</th>
        <td>{{entity.cdefine5}}%</td>
      </tr>
      <tr>
        <th>业务类型</th>
        <td>{{entity.ywlxName}}</td>
      </tr>
      <tr>
        <th>状态</th>
        <td>{{entity.statusName}}</td>
      </tr>
      <tr>
        <th>创建人</th>
        <td>{{entity.createuser}}</td>
      </tr>
      <tr>
        <th>创建日期</th>
        <td><DateFormat :value="entity.createtime" :format="'YYYY-MM-DD HH:mm'"></DateFormat></td>
      </tr>
      <tr>
        <th>备注</th>
        <td>{{entity.remark}}</td>
      </tr>
      <tr>
        <th>盘点范围</th>
        <td>
          <p v-for="(item,index) in state.selectedCkList">{{item}}</p>
        </td>
      </tr>
    </table>
  </div>
</template>

<script setup name="viewPlan">
import request from '/@/utils/request';
import {reactive, ref, onMounted, defineProps, defineEmits, nextTick} from "vue";
import PlanZq from "/@/utils/PlanZq";

let props = defineProps({
  planId : {type : Number, default: 0}
})
let entity = ref({})
const state = reactive({
  selectedCkList : [],
  PlanZq:PlanZq
})
const loadEntity = ()=>{
  if(props.planId > 0){
    request({ url: '/plan/getplan', data: {id : props.planId} }).then( res =>{
      entity.value = res.data.plan
      state.selectedCkList = res.data.plancangkus.map(function (value,index,array){
        return value.cWhName
      })
    })
  }
}
onMounted(()=>{
  loadEntity();
})
</script>

<style scoped>

</style>
